﻿using System;
using System.Security.Cryptography;
using System.Text;

namespace Framework.Business
{
    public static class HashHelper
    {
        private const string HashKey =
            "bd1f4ba58ad04a29aa5afce720a60f4b04926358e5074134ae057e30a83a5411" +
            "88b2271ca25e40f288b4d2ae0966a1bb022136cccc334c1488a815cfebd47ca2";

        public static string Hash(string data)
        {
            if (string.IsNullOrWhiteSpace(data))
            {
                throw new ArgumentNullException("data");
            }

            using (var hash = new HMACMD5(Encoding.UTF8.GetBytes(HashKey)))
            {
                var hashBytes =
                    hash.ComputeHash(Encoding.UTF8.GetBytes(data));

                return hashBytes.ToHexString(true);
            }
        }

    }
}
